package com.cyy.user.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.cyy.user.pojo.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * user数据访问接口
 * @author Administrator
 *
 */
public interface UserDao extends JpaRepository<User,String>,JpaSpecificationExecutor<User>{

    User findByMobile(String mobile);

    //更新粉丝数
    @Modifying
    @Query("update User u set u.fanscount = u.fanscount + ?2 where u.id = ?1 ")
    public void incFanscount(String userid,int fan);

    //更新关注数
    @Modifying
    @Query("update User u set u.followcount = coalesce(u.followcount,0) + ?2 where u.id = ?1 ")
    public void incFollowcount(String userid,int fan);
}
